package huawei;

public class Question5 {

    public int jumpTimes(int n, int now) {
        if (n == now) return 1;
        if (n < now) return 0;
        int n1 = jumpTimes(n, now + 1);
        int n3 = jumpTimes(n, now + 3);
        return n1 + n3;
    }

    public  int countWays(int n) {
        if (n < 0) {
            return 0;
        }
        if (n == 0) {
            return 1;
        }
        int[] dp = new int[n + 1];
        dp[0] = 1;
        dp[1] = 0;
        dp[2] = 0;
        dp[3] = 2;

        for (int i = 4; i <= n; i++) {
            dp[i] = dp[i - 1] + dp[i - 3];
        }

        return dp[n];
    }

    public static void main(String[] args) {
        Question5 question5 = new Question5();
        System.out.println(question5.jumpTimes(4, 0));
        System.out.println(question5.countWays(4));
    }
}
